import logging
import allure
import requests
from utils.database import DataBase
from utils.decorator import http_request_wrapper
from utils.slow_api_write_csv import ApiLogger
from utils.http_requester import HttpRequester



@http_request_wrapper
def send_http_request(**request_data):
    # return HttpRequester().send_request(**request_data)
    return request_data



    # res = requests.request(**request_data)
    #
    # response = {
    #     "status_code": res.status_code,
    #     "json_data": res.json(),
    #     "response_time": res.elapsed.total_seconds() * 1000
    # }
    #
    # # 写入慢接口
    # ApiLogger().log_request(res.url, request_data["method"], request_data["params"], request_data["data"],
    #                         request_data["json"], response["response_time"])
    #
    # logging.info(f"2. 发送HTTP请求，响应内容: {response}")
    # return response


def send_jdbc_request(sql):
    return DataBase().get_one(sql)

    # conn = pymysql.Connect(
    #     host=DB_HOST,
    #     port=DB_PORT,
    #     user=DB_USER,
    #     passwd=DB_PASSWORD,
    #     database=DB_NAME,
    #     charset=CHARSET,
    #     autocommit=AUTOCOMMIT
    # )
    #
    # # 创建游标
    # cur = conn.cursor()
    # # 执行语句
    # cur.execute(sql)
    # result = cur.fetchone()
    # # 关闭游标
    # cur.close()
    # # 断开连接
    # conn.close()
    # return result[index]
